/*****************************************
 * Abhishek Mahanti - amahanti@umich.edu *
 * EECS 281 - Project 1   LM:9.28        *
 * ************************************* */
 
#include<iostream>
#include<fstream>
#include<string.h>
#include "classes.cpp"

using namespace std;

#define MAXLINE   1000

int main(int argc, char* argv[])  {
    char lineofmap[MAXLINE],version[MAXLINE],level[MAXLINE];
    class map currentMap;
    ifstream mapFile(argv[1]);
    
    
    while(!mapFile.eof())   {
        mapFile.getline(lineofmap,MAXLINE);
        if((lineofmap[0]=='n')&&(lineofmap[1]=='l')&&(lineofmap[2]=='e'))
        {
            currentMap.setLevels(lineofmap[8] - '0');
        }
        else if((lineofmap[0]=='v')&&(lineofmap[1]=='e')&&(lineofmap[2]=='r'))
        {
            //store version number somehow
        }
        else if( (lineofmap[0] == '#'))    {
            //DO NOTHING BUT DO SOMETHING
        }
        else if((lineofmap[0]=='l')&&(lineofmap[1]=='e')&&(lineofmap[2]=='v'))
        {
            //the madness begins
            //set levels to int
            int levelNumber = (lineofmap[6] + '0' - 96);
            //set dimensions for levelNumber
            mapFile.getline(lineofmap,MAXLINE);
            currentMap.floorArray[levelNumber].setSize(lineofmap[10] + '0' - 96);
                //NEED TO MAKE THIS WORK FOR MORE THAN 1 DIGIT
            for(int i=0;i<currentMap.floorArray[levelNumber].getDimension();i++)
            {
                mapFile.getline(lineofmap,MAXLINE);
                int lineLength = sizeof(lineofmap);
                //need array of char pointers pointing to char arrays. tiles.
                //tiles should be part of floor. floor 1 needs 8*8.
                //currentMap.floorArray[levelNumber].allTilesAry = new tile[lineLength];
                for(int i=0;i<lineLength;i++)   {
                }
            }
        }
        else if((lineofmap[0]=='d')&&(lineofmap[1]=='i')&&(lineofmap[2]=='m'))
        {
            //dimension
            //floorArray[1].setSize(8);
        }
        else if((lineofmap[0]=='m')&&(lineofmap[1]=='a')&&(lineofmap[2]=='p'))
        {
        }
    }
    
        mapFile.close();
}
